package com.pers.springcloud.entities;

import lombok.Data;

/**
 * @author huangjian
 */
@Data
public class JsonResultVo {

    private Integer code;
    private String msg;
    private Object data;

    private JsonResultVo() {
    }

    private JsonResultVo(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private JsonResultVo(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     *
     * @param data
     * @return
     */
    public static JsonResultVo success(Object data) {
        return new JsonResultVo(200, "success", data);
    }

    /**
     *
     * @return
     */
    public static JsonResultVo success() {
        return new JsonResultVo(200, "success");
    }

    /**
     *
     * @param data
     * @return
     */
    public static JsonResultVo error(Object data) {
        return new JsonResultVo(500, "error", data);
    }

    /**
     *
     * @return
     */
    public static JsonResultVo error() {
        return new JsonResultVo(500, "error");
    }

    /**
     *
     * @param msg
     * @return
     */
    public static JsonResultVo error(String msg) {
        return new JsonResultVo(500, msg);
    }

    /**
     *
     * @param msg
     * @return
     */
    public static JsonResultVo success(String msg) {
        return new JsonResultVo(200, msg);
    }

    /**
     *
     * @param msg
     * @param data
     * @return
     */
    public static JsonResultVo error(String msg, Object data) {
        return new JsonResultVo(500, msg, data);
    }

    /**
     *
     * @param msg
     * @param data
     * @return
     */
    public static JsonResultVo success(String msg, Object data) {
        return new JsonResultVo(200, msg, data);
    }


}
